%% 顺序结构
x = -2.3 : 0.1 : 0.8;
y = -1.5 : 0.1 : 1.5;
[x, y] = meshgrid(x, y); % 确定离散点横坐标和纵坐标
z = exp(-(x.^2 + y.^2)); % 产生二元函数自变量域的离散点
z(20:32, 1:14)=zeros(13, 14); % 修改部分函数值为零
mesh(z); % 根据离散点处函数值绘图
%% 选择结构
x1 = 0 : 0.01 : 2 * pi;
if (1 == 1)
	plot(x1, sin(x1));
else
	plot(x1, cos(x1));
end
if (2 == 1)
	plot(x1, sin(x1));
end
a = 3;
if (1 == a)
	plot(x1, sin(x1));
elseif (2 == a)
	plot(x1, cos(x1));
else
    plot(x1, tan(x1));
end

Simulink.defineIntEnumType('BasicColors', ... 
                        {'Red', 'Yellow', 'Blue'}, ...
                        [0;1;2], ... 
                        'Description', 'Basic colors', ...
                        'DefaultValue', 'Red', ...
                        'HeaderFile', 'mybasiccolors.h', ...
                        'DataScope', 'Exported', ...
                        'AddClassNameToEnumNames', true, ...
                        'StorageType', 'uint8');

Enum_a = BasicColors.Blue;
switch Enum_a
    case BasicColors.Blue 
        plot(x1, sin(x1), 'b');
    case BasicColors.Red
        plot(x1, sin(x1), 'r');
    case BasicColors.Yellow
        plot(x1, sin(x1), 'y');
    otherwise
        plot(x1, sin(x1), 'k');
end

try 
	uint8_a = uint8(10);
    uint16_a = uint16(10);
    uint16_b = uint8_a + uint16_a;
catch ME
    warning(ME.message);
	uint8_a = uint8(10);
    uint16_a = uint16(10);
    uint16_b = uint16(uint8_a) + uint16_a;
end
% for循环实现乘方算法
var = 10;
var_n = 1;
for ii = 1 : var
    var_n = var_n * var;
    disp(ii);
    disp(var_n);
end
% while循环实现乘方算法
var = 10;
var_n = 1;
ii = 1;
while ii <= var
	var_n = var_n * var;
    disp(ii);
    disp(var_n);
    ii = ii + 1;
end

